package com.xk857.school.controller.pub;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xk857.entities.Card;
import com.xk857.school.req.CardREQ;
import com.xk857.school.service.IMyCardService;
import com.xk857.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author CV大魔王
 * @Description
 * @date 2021/5/2 19:35
 */
@Api(value = "校园卡找回接口(公共)", tags = "校园卡找回接口(公共)")
@RestController
@RequestMapping("/pub/card")
public class PubCardController {

    @Autowired
    private IMyCardService myCardService;

    @ApiOperation("条件查询校园卡接口")
    @PostMapping("/search")
    public IPage<Card> queryPage(@RequestBody CardREQ req) {
        return myCardService.queryPage(req);
    }

    @ApiOperation("根据校园卡状态统计数量")
    @GetMapping("/count")
    public Result queryCount(@ApiParam(name = "status", value = "校园卡状态,0已删除 1捡卡 2已找回 3丢卡 4已补办", required = true) String status) {
        return Result.ok(myCardService.queryCount(status));
    }

    @ApiOperation("查询学校列表")
    @GetMapping("/getSchoolName")
    public Result getSchoolName() {
        return myCardService.getSchoolNameList();
    }

    @ApiOperation("本月校园卡信息发布数量")
    @GetMapping("/count/month")
    public Result queryCountMonth() {
        return Result.ok(myCardService.queryCountMonth());
    }

    @ApiOperation("上月校园卡信息发布数量")
    @GetMapping("/count/month/first")
    public Result queryCountMonthFirst() {
        return Result.ok(myCardService.queryCountFirstMonth());
    }

    @ApiOperation("本周校园卡信息发布数量")
    @GetMapping("/count/week")
    public Result queryCountWeek() {
        return Result.ok(myCardService.queryCountWeek());
    }

    @ApiOperation("本月校园卡信息发布数量")
    @GetMapping("/count/week/first")
    public Result queryCountWeekFirst() {
        return Result.ok(myCardService.queryCountFirstWeek());
    }


}
